<template>
    <div>
        <el-form :inline="true" class="demo-form-inline" v-if="type=='计算'||type=='支付'">
            <el-form-item label="当日美元汇率">
                <el-input v-model="huilv" placeholder="当日美元汇率"></el-input>
                <span v-if="type=='支付'"> (此为美元对人民币汇率 例如6.7488)</span>
                <span v-else>
                    (此为人民币对美元汇率 例如0.1482)
                </span>
            </el-form-item>

        </el-form>
        <el-table :data="list" border style="width: 100%" height="400">          
            <el-table-column prop="REPORTINFORMATION_ID" label="报案号" width="200">
            </el-table-column>
              <el-table-column prop="RIID" label="报案编码" width="300">
            </el-table-column>
            <el-table-column prop="REPORTINFORMATION_CAUSE" label="本次报案事由" width="300">
            </el-table-column>
              <el-table-column prop="Reason" label="出险原因" width="300">
            </el-table-column>
            <el-table-column prop="PRODUCTNAME" label="产品名称" width="200">
            </el-table-column>
            <el-table-column prop="CUSTNAME" label="被保险人姓名" width="150">
            </el-table-column>
            <el-table-column label="操作" width="150">
                <template scope="scope">
                    <el-button type="text" size="media" @click="gocheck(scope.row.RIID,scope.row.REPORTINFORMATION_ID)">
                        <i class="el-icon-view" v-if="type=='医师审核' || type=='理赔审核'"> 审核</i>
                        <i class="el-icon-view" v-if="type=='新增'"> 添加</i>
                        <i class="el-icon-view" v-if="type=='修改'"> 修改</i>
                        <i class="el-icon-view" v-if="type=='查看'"> 查看</i>
                        <i class="el-icon-view" v-if="type=='计算'"> 计算</i>
                        <i class="el-icon-view" v-if="type=='计算完成'">查看结果</i>
                        <i class="el-icon-view" v-if="type=='支付'">查看支付金额</i>
                        <i class="el-icon-view" v-if="type=='支付查看'">查看</i>
                    </el-button>
                </template>
            </el-table-column>
        </el-table>
        <div class="block">
            <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage1" :page-size="10" layout="total, prev, pager, next" :total="pagecount">
            </el-pagination>
        </div>
    </div>
</template>
<script>
import {
    mapState
} from 'vuex';
export default {
    data() {
        return {
            list: [],
            currentPage1: 1,
            pagecount: 0,
            huilv: ""
        }
    },
    computed: mapState({
        typenumber: state => state.typenumber.number,
        typenumber2: state => state.typenumber.number2,
    }),
    props: {
        titleList: {
            type: Array,
            default: []
        },
        //类型 审核 /理赔录入
        type: {
            type: String,
            default: "新增"
        },
        //显示的类型
        DutyType: {
            type: String,
            default: "医疗保险"
        },
        //显示的状态
        getStyle: {
            type: String,
            default: "审核通过"
        },
        //目标URL        
        goUrl: {
            type: String,
            default: "goUrl"
        }
    },
    methods: {
        handleSizeChange(val) {

        },
        handleCurrentChange(val) {
            this.currentPage1 = val;

            this.$http.get("Lipei?pagesize=10&type=" + this.DutyType + "&style=" + this.getStyle + "&page=" + val).then(response => {
                var data = response.body;
                if (data.code == 1) {
                    this.list = data.result;
                } else {
                    this.$notify.error({
                        title: '失败',
                        message: '数据获取失败'
                    });
                }
            }, response => {
                this.$notify.error({
                    title: '网络错误',
                    message: '网络错误'
                });
                this.loding = false;
            });
        },
        gocheck(id, rid) {

            switch (this.type) {
                case "新增":
                    this.$router.push({
                        name: "lipeiaddForm",
                        query: {
                            id: id,
                            type: this.DutyType,
                            rid: rid
                        }
                    });
                    break;
                case "医师审核":
                    this.$router.push({
                        name: "yishicheckForm",
                        query: {
                            id: id,
                            type: this.DutyType,
                            rid: rid
                        }
                    });
                    break;
                case "理赔审核":
                    this.$router.push({
                        name: "lipeicheckForm",
                        query: {
                            id: id,
                            type: this.DutyType,
                            rid: rid
                        }
                    });
                    break;
                case "修改":
                    this.$router.push({
                        name: "lipeitaskform",
                        query: {
                            id: id,
                            type: this.DutyType,
                            rid: rid,
                            nextType:'修改'
                        }
                    });
                    break;
                case "查看":
                    this.$router.push({
                        name: "lipeitaskform",
                        query: {
                            id: id,
                            type: this.DutyType,
                            rid: rid,
                            nextType:'查看'
                        }
                    });
                    break;
                case "计算":
                    this.jisuan(id);
                    break;
                case "计算完成":
                    if (this.DutyType == "医疗保险") {
                        this.$router.push({
                            name: 'lipeitaskResultMedical',
                            query: {
                                id: id
                            }
                        })
                    } else {
                        this.$router.push({
                            name: "jisuanResultForm",
                            query: {
                                id: id,
                                type: this.DutyType,
                                rid: rid
                            }
                        });
                    }
                    break;
                case "支付":
                    this.zhifu(id);
                    break;
                case "支付查看":
                    if (this.DutyType == "医疗保险") {
                        this.$router.push({
                            name: 'jisuanResultMedical',
                            query: {
                                id: id
                            }
                        })
                    } else {
                        this.$router.push({
                            name: "lipeiResultForm",
                            query: {
                                id: id,
                                type: this.DutyType,
                                rid: rid
                            }
                        });
                    }
                    break;

            }
        },
        jisuan(id) {
            // console.log(0);
            var url;
            if (this.huilv == "") {
                this.$notify.error({
                    title: '请输入汇率',
                    message: '请输入汇率'
                })
                this.loading = false;
                return;
            }
            switch (this.DutyType) {
                case "医疗保险":
                    url = "Bill/sum?id=" + id + "&huilv=" + this.huilv;
                    break;
                case "意外残疾":
                    url = "BILL_INJURE/Compute?id=" + id;
                    break;
                case "意外死亡":
                    url = "Bill_Died/Compute?id=" + id;
                    break;
                case "紧急医疗":
                    url = "BILL_HMEDIA/Compute?id=" + id + "&lilv=" + this.huilv;
                    break;
                case "紧急转院":
                    url = "BILL_HCHANGE/Compute?id=" + id + "&lilv=" + this.huilv;
                    break;
                case "紧急运返":
                    url = "BILL_HBACK/Compute?id=" + id + "&lilv=" + this.huilv;
                    break;
                case "陪同费":
                    url = "BILL_HACCOMPANY/Compute?id=" + id + "&lilv=" + this.huilv;
                    break;
                case "遗体运返或安葬":
                    url = "BILL_HBURIAL/Compute?id=" + id + "&lilv=" + this.huilv;
                    break;
                case "探访费":
                    url = "BILL_HVISIT/Compute?id=" + id + "&lilv=" + this.huilv;
                    break;
                case "学业中断":
                    url = "BILL_ACADEMIC/Compute?id=" + id + "&lilv=" + this.huilv;
                    break;
                case "旅行延误":
                    url = "BILL_TRAVELDELAY/Compute?id=" + id + "&lilv=" + this.huilv;
                    break;
                case "物品丢失":
                    url = "BILL_LOSE/Compute?id=" + id + "&lilv=" + this.huilv;
                    break;
                case "个人第三者":
                    url = "BILL_OTHER/Compute?id=" + id + "&lilv=" + this.huilv;
                    break;
            }
            this.$http.get(url).then(response => {
                var data = response.body;
                if (data.code == 1) {
                    this.$notify.success({
                        title: '计算完成',
                        message: '计算完成'
                    });
                    this.getData();
                } else {
                    this.$notify.error({
                        title: '失败',
                        message: data.msg
                    });
                }
            }, response => {
                this.$notify.error({
                    title: '网络错误',
                    message: '网络错误'
                });
            })
        },
        zhifu(id) {
            var url;
            if (this.huilv == "") {
                this.$notify.error({
                    title: '请输入汇率',
                    message: '请输入汇率'
                })
                this.loading = false;
                return;
            }
            // if (this.DutyType == "医疗保险") {
                this.$router.push({
                    name: 'zhifuqurenForm',
                    query: {
                        id: id,
                        huilv: this.huilv,
                        DutyType:this.DutyType
                    }
                })

            // } else {
            //     url = "ResultOther/Pay?id=" + id + "&type=" + this.DutyType + "&huilv=" + this.huilv;
            //     this.$http.get(url).then(response => {
            //         var data = response.body;
            //         if (data.code == 1) {
            //             this.$notify.success({
            //                 title: '成功',
            //                 message: '确认成功'
            //             });
            //             this.getData();
            //         } else {
            //             this.getData();
            //             this.$notify.error({
            //                 title: '失败',
            //                 message: '确认失败'
            //             })

            //         }
            //     }, response => {
            //         this.$notify.error({
            //             title: '网络错误',
            //             message: '网络错误'
            //         });
            //         this.loding = false;
            //     });
            // }


        },
        getData() {
            if (this.DutyType == "医疗保险" && this.type == "支付") {
                this.getStyle = "折扣完成";
            }
            this.$http.get("Lipei?pagesize=10&page=1&type=" + this.DutyType + "&style=" + this.getStyle).then(response => {
                var data = response.body;
                if (data.code == 1) {
                    this.list = data.result;
                    switch (this.DutyType) {
                        case '医疗保险':
                            if (this.getStyle != '理赔审核不通过') {
                                this.typenumber.medical = data.pagecount;
                            } else {
                                this.typenumber2.medical = data.pagecount;
                            }

                            break;
                        case '意外死亡':
                            if (this.getStyle != '理赔审核不通过') {
                                this.typenumber.harmDie = data.pagecount;
                            } else {
                                this.typenumber2.harmDie = data.pagecount;
                            }

                            break;
                        case '意外残疾':
                            if (this.getStyle != '理赔审核不通过') {
                                this.typenumber.harmDisability = data.pagecount;
                            } else {
                                this.typenumber2.harmDisability = data.pagecount;
                            }

                            break;
                        case '紧急医疗':
                         if (this.getStyle != '理赔审核不通过') {
                                this.typenumber.rescueMeidca = data.pagecount;
                            } else {
                                this.typenumber2.rescueMeidca = data.pagecount;
                            }                           
                            break;
                        case '紧急转院':
                            if (this.getStyle != '理赔审核不通过') {
                                this.typenumber.rescueMove = data.pagecount;
                            } else {
                                this.typenumber2.rescueMove = data.pagecount;
                            }

                            break;
                        case '紧急运返':
                            if (this.getStyle != '理赔审核不通过') {
                                this.typenumber.rescueReturned = data.pagecount;
                            } else {
                                this.typenumber2.rescueReturned = data.pagecount;
                            }

                            break;
                        case '陪同费':
                            if (this.getStyle != '理赔审核不通过') {
                                this.typenumber.rescueVisit = data.pagecount;
                            } else {
                                this.typenumber2.rescueVisit = data.pagecount;
                            }

                            break;
                        case '遗体运返或安葬':
                            if (this.getStyle != '理赔审核不通过') {
                                this.typenumber.rescueAccompany = data.pagecount;
                            } else {
                                this.typenumber2.rescueAccompany = data.pagecount;
                            }

                            break;
                        case '探访费':
                            if (this.getStyle != '理赔审核不通过') {
                                this.typenumber.rescueInter = data.pagecount;
                            } else {
                                this.typenumber2.rescueInter = data.pagecount;
                            }

                            break;
                        case '学业中断':
                            if (this.getStyle != '理赔审核不通过') {
                                this.typenumber.studyBreak = data.pagecount;
                            } else {
                                this.typenumber2.studyBreak = data.pagecount;
                            }

                            break;
                        case '旅行延误':
                            if (this.getStyle != '理赔审核不通过') {
                                this.typenumber.travelDelay = data.pagecount;
                            } else {
                                this.typenumber2.travelDelay = data.pagecount;
                            }

                            break;
                        case '物品丢失':
                            if (this.getStyle != '理赔审核不通过') {
                                this.typenumber.travelLose = data.pagecount;
                            } else {
                                this.typenumber2.travelLose = data.pagecount;
                            }

                            break;
                        case '个人第三者':
                            if (this.getStyle != '理赔审核不通过') {
                                this.typenumber.three = data.pagecount;
                            } else {
                                this.typenumber2.three = data.pagecount;
                            }

                            break;
                    }
                    this.pagecount = data.pagecount;
                } else {
                    this.$notify.error({
                        title: '失败',
                        message: '数据获取失败'
                    });
                }
            }, response => {
                this.$notify.error({
                    title: '网络错误',
                    message: '网络错误'
                });
                this.loding = false;
            });
        }
    },
    activated() {
      
        this.currentPage1=1;
        this.getData();
    }
}
</script>
<style>

</style>